package request;

import java.io.OutputStream;

import core.GameUser;
import java.util.Vector;
import response.ResponseChatPublic;

/**
 * Request for handling public chatting, which representing one user
 * chat with all other users in the same map.
 *
 * @author gary
 *
 */
public class RequestChatPublic extends GameRequest {

    private GameUser user;
    private int user_id;
    private String message;
    private Vector<Integer> userList;

    @Override
    public void parse() {
        // The message sent from the client
        message = client.readString(dataIn);
        user = client.getUser();
        user_id = user.getID();
        // Users of the same map
        /* TODO implement
        userList = gameServer.getUserListForMap(user.getMapId());
         *
         */
    }

    @Override
    public void respond(OutputStream output) {
        // Create a public chat response
        ResponseChatPublic response = new ResponseChatPublic();
        // Set up reference
        response.set(gameServer);
        response.setUser(user);
        response.setContent(message);
        // Need to update other's queue with this response
        /* TODO implement
        gameServer.updateOthersQueue(response, gameServer.getActiveUserListByUserId(userList), user_id);
         *
         */
    }
}